package stocks.client.gui.controller.actions;

import stocks.client.gui.model.model;
import stocks.server.CallBack;

import java.awt.event.ActionEvent;
import java.rmi.RemoteException;

import javax.swing.AbstractAction;

public class SellStockAction extends AbstractAction{

	private model m;
	
	/**
	 * Constructor, takes model as a parameter
	 */
	public SellStockAction(model m)
	{
		this.m = m;
	}
	@Override
	public void actionPerformed(ActionEvent e) {
		// TODO Auto-generated method stub
		String qty_ = m.getBuySellFrame().getQty();
		int qty = Integer.parseInt(qty_);
		
		String sname_ = m.getBuySellFrame().getStockName();
		
		String price_ = m.getBuySellFrame().getPrice();
		int price = Integer.parseInt(price_);
		
		CallBack c = m;
		try {
			m.getRMIInterface().requestSell(c , sname_, price, qty);
		} catch (RemoteException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}
	}

}
